//author:jxx
//此处是对表单的方法，组件，权限操作按钮等进行任意扩展(方法扩展可参照SellOrder.js)
let extension = {
    components: {//动态扩充组件或组件路径
        //表单header、content、footer对应位置扩充的组件
        gridHeader: '',//{ template: "<div>扩展组xx件</div>" },
        gridBody: '',
        gridFooter: '',
        //弹出框(修改、编辑、查看)header、content、footer对应位置扩充的组件
        modelHeader: '',
        modelBody: '',
        modelFooter: ''
    },
    buttons: { view: [], box: [], detail: [] },//扩展的按钮
    methods: {//事件扩展
        getFormOption (field) {
            let option;
            this.editFormOptions.forEach(x => {
                x.forEach(item => {
                    if (item.field == field) {
                        option = item;
                    }
                })
            })
            return option;
        },
        onInit () {
            let merchantCode = this.getFormOption('merchantCode')
            let pay_code = this.getFormOption('pay_code')
            merchantCode.onChange = (v, b) => {
                let parmas = {
                    order: "desc",
                    page: 1,
                    rows: 30,
                    sort: "id",
                    wheres: `[{\"name\":\"merchants_id\",\"value\":\"${v}\",\"displayType\":\"text\"}]`,
                }
                this.http.post('/api/SmallPayConfiguration/getPageData', parmas).then(res => {
                    pay_code.data = []
                    pay_code.data = res.rows.map(i => {
                        return {
                            key: i.code,
                            value: i.name
                        }
                    })
                })
            }
        },
        modelOpenBefore (row) {
            let pay_code = this.getFormOption('pay_code')
            if (row) {
                let parmas = {
                    order: "desc",
                    page: 1,
                    rows: 30,
                    sort: "id",
                    wheres: `[{\"name\":\"merchants_id\",\"value\":\"${row.merchantCode}\",\"displayType\":\"text\"}]`,
                }
                this.http.post('/api/SmallPayConfiguration/getPageData', parmas).then(res => {
                    pay_code.data = res.rows.map(i => {
                        return {
                            key: i.code,
                            value: i.name
                        }
                    })
                    
                    if (row.pay_code.includes(',')) {
                        this.editFormFields.pay_code = row.pay_code.split(',')
                    }
                })
            } else {
                console.log("新建操作")
            }
        },
        rowClick ({ row, column, event }) {
            this.$refs.table.$refs.table.toggleRowSelection(row);
            return true;
        },
    }
};
export default extension;